class EventsController < ApplicationController

  def index
	@upcoming_events = Events.upcoming_events
	
  end


#new events
  def new
	@events = Events.new
  end
#show events
  def show
	@events = Events.find(params[:id])
  end
#create new events
  def create
	@events = Events.new(params[:events])
	if @events.save
	  flash[:notice] = 'Event Successfully Scheduled'
	  redirect_to :action => "index"
	else
	  render :action => "new"
	end
  end
#delete events
  def destroy
	@events = Events.find(params[:id])
 	@events.destroy

 	flash[:notice] = 'Event successfully cancelled'
 	redirect_to :action => "index"
  end
#edit events
  def update
	@events = Events.find(params[:id])

	if @events.update_attributes(params[:events])
	  flash[:notice] = 'Event successfully updated.'
	  redirect_to :action => "show", :id => params[:id]
	else
	  render :action => "edit"
	end
  end
#edit events
def edit
	@events= Events.find(params[:id])
  end
end
